package com.highcom;

import com.highcom.bean.User;
import com.highcom.config.MyConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class Springboot0104ConfigurationApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext run = SpringApplication.run(Springboot0104ConfigurationApplication.class, args);
        String[] names = run.getBeanDefinitionNames();
        for (String name : names) {
            System.out.println("name = " + name);
        }

//        User u1 = run.getBean("user01", User.class);
//        User u2 = run.getBean("user01", User.class);
////對比
//        System.out.println(u1 == u2);
        MyConfig bean = run.getBean(MyConfig.class);
        User user1 = bean.user01();
        User user2 = bean.user01();
        System.out.println(user1 == user2);
    }

}
